import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalMyorderPage(Base):
    """
    我的积分页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.order_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.order_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 订单tab
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(""))

        # 订单tab选中图标
        self.order_list_to_be_paid_select_icon = (By.XPATH, Personal.my_order_list_tab_title_icon.format(""))

        # 我的订单封面
        self.order_list_cover_img = (By.XPATH, Personal.my_order_list_order_img.format(""))

        # 我的订单酒店名称
        self.order_list_hotel_name_text = (By.XPATH, Personal.my_order_list_order_hotel_name_text.format(""))

        # 我的订单支付状态
        self.order_list_payment_status_text = (By.XPATH, Personal.my_order_list_order_payment_status_text.format(""))

        # 我的订单床型
        self.order_list_bed_type_text = (By.XPATH, Personal.my_order_list_order_bed_type_text.format(""))

        # 我的订单支付金额
        self.order_list_payment_amount_text = (By.XPATH, Personal.my_order_list_order_payment_amount_text.format(""))

        # 我的订单入住时间
        self.order_list_check_time_text = (By.XPATH, Personal.my_order_list_order_check_time_text.format(""))

        # 我的订单创建时间
        self.order_list_create_time_text = (By.XPATH, Personal.my_order_list_order_create_time_text.format(""))

        # 我的订单下方按钮
        self.order_list_select_btn = (By.XPATH, Personal.my_order_list_order_select_btn.format(""))

        # 我的订单剩余时间
        self.order_list_time_left_text = (By.XPATH, Personal.my_order_list_order_time_left_text.format(""))

        # 暂无数据文案
        self.order_no_data_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_tips"))

        # 暂无数据图标
        self.order_no_data_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_tips"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.order_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.order_back_btn)

    def click_list_to_be_paid(self, index=1):
        """
        点击待支付按钮
        index默认选择1
        :return:None
        """
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(index))
        self.click_element(self.order_list_to_be_paid_btn)

    def get_list_to_be_paid_select(self, index=1):
        """
        获取待支付按钮选中图标
        index默认选择1
        :return:None
        """
        self.order_list_to_be_paid_select_icon = (By.XPATH, Personal.my_order_list_tab_title_icon.format(index))
        return self.find_element_o(self.order_list_to_be_paid_select_icon)

    def click_list_to_be_confirmed(self, index=2):
        """
        点击待确认按钮
        index默认选择2
        :return:None
        """
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(index))
        self.click_element(self.order_list_to_be_paid_btn)

    def get_list_to_be_confirmed_select(self, index=2):
        """
        获取待确认按钮选中图标
        index默认选择2
        :return:None
        """
        self.order_list_to_be_paid_select_icon = (By.XPATH, Personal.my_order_list_tab_title_icon.format(index))
        return self.find_element_o(self.order_list_to_be_paid_select_icon)

    def click_list_completed(self, index=3):
        """
        点击待确认按钮
        index默认选择3
        :return:None
        """
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(index))
        self.click_element(self.order_list_to_be_paid_btn)

    def get_list_completed_select(self, index=3):
        """
        获取已完成按钮选中图标
        index默认选择3
        :return:None
        """
        self.order_list_to_be_paid_select_icon = (By.XPATH, Personal.my_order_list_tab_title_icon.format(index))
        return self.find_element_o(self.order_list_to_be_paid_select_icon)

    def click_list_closed(self, index=4):
        """
        点击已关闭按钮
        index默认选择3
        :return:None
        """
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(index))
        self.click_element(self.order_list_to_be_paid_btn)

    def get_list_closed_select(self, index=4):
        """
        获取已完成按钮选中图标
        index默认选择4
        :return:None
        """
        self.order_list_to_be_paid_select_icon = (By.XPATH, Personal.my_order_list_tab_title_icon.format(index))
        return self.find_element_o(self.order_list_to_be_paid_select_icon)

    def get_to_be_paid_selected(self, index=1):
        """
        获取待支付按钮属性
        index默认选择1
        :return:None
        """
        self.order_list_to_be_paid_btn = (By.XPATH, Personal.my_order_list_tab_title_text.format(index))
        return self.find_element_o(self.order_list_to_be_paid_btn)

    def get_list_cover(self, index=1):
        """
        获取订单图片
        index默认选择1
        :return:None
        """
        self.order_list_cover_img = (By.XPATH, Personal.my_order_list_order_img.format(index))
        return self.find_element_o(self.order_list_cover_img)

    def get_list_hotel_name(self, index=1):
        """
        获取订单酒店名称
        index默认选择1
        :return:None
        """
        self.order_list_hotel_name_text = (By.XPATH, Personal.my_order_list_order_hotel_name_text.format(index))
        return self.find_element_o(self.order_list_hotel_name_text)

    def get_list_payment_status(self, index=1):
        """
        获取订单支付状态
        index默认选择1
        :return:None
        """
        self.order_list_payment_status_text = (By.XPATH, Personal.my_order_list_order_payment_status_text.format(index))
        return self.find_element_o(self.order_list_payment_status_text)

    def get_list_bed_type(self, index=1):
        """
        获取订单床型
        index默认选择1
        :return:None
        """
        self.order_list_bed_type_text = (By.XPATH, Personal.my_order_list_order_bed_type_text.format(index))
        return self.find_element_o(self.order_list_bed_type_text)

    def get_list_payment_amount(self, index=1):
        """
        获取订单支付金额
        index默认选择1
        :return:None
        """
        self.order_list_payment_amount_text = (By.XPATH, Personal.my_order_list_order_payment_amount_text.format(index))
        return self.find_element_o(self.order_list_payment_amount_text)

    def get_list_check_time(self, index=1):
        """
        获取订单入住时间
        index默认选择1
        :return:None
        """
        self.order_list_check_time_text = (By.XPATH, Personal.my_order_list_order_check_time_text.format(index))
        return self.find_element_o(self.order_list_check_time_text)

    def get_list_create_time(self, index=1):
        """
        获取订单创建时间
        index默认选择1
        :return:None
        """
        self.order_list_create_time_text = (By.XPATH, Personal.my_order_list_order_create_time_text.format(index))
        return self.find_element_o(self.order_list_create_time_text)

    def click_list_pay_immediately(self, index=1):
        """
        点击立即支付按钮
        index默认选择1
        :return:None
        """
        self.order_list_select_btn = (By.XPATH, Personal.my_order_list_order_select_btn.format(index))
        self.click_element(self.order_list_select_btn)

    def click_list_dial_number(self, index=2):
        """
        点击拨打电话按钮
        index默认选择2
        :return:None
        """
        self.order_list_select_btn = (By.XPATH, Personal.my_order_list_order_select_btn.format(index))
        self.find_element_o(self.order_list_select_btn)

    def click_list_navigate_to(self, index=3):
        """
        点击导航前往按钮
        index默认选择3
        :return:None
        """
        self.order_list_select_btn = (By.XPATH, Personal.my_order_list_order_select_btn.format(index))
        self.find_element_o(self.order_list_select_btn)

    def get_list_time_left(self, index=1):
        """
        获取剩余支付时间
        index默认选择2
        :return:None
        """
        self.order_list_time_left_text = (By.XPATH, Personal.my_order_list_order_time_left_text.format(index))
        return self.find_element_o(self.order_list_time_left_text)

    def get_no_data_text(self):
        """
        获取暂无数据文案

        :return:获取元素
        """
        return self.find_element_o(self.order_no_data_text)

    def get_no_data_icon(self):
        """
        获取暂无数据文案

        :return:获取元素
        """
        return self.find_element_o(self.order_no_data_icon)

    def is_display_no_data(self):
        """
        判断是否存在暂无数据

        :return:获取元素
        """
        return self.is_display(self.order_no_data_text)